package vn.edu.ptithcm.pim.dao;

import vn.edu.ptithcm.pim.dom.Company;

import java.util.List;

import org.hibernate.LockMode;
import org.hibernate.Transaction;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;


@SuppressWarnings("rawtypes")
public class CompanyDao extends HibernateDaoSupport {

	public void save(Company company) {
		try {
			Transaction tx = getSession().beginTransaction();
			getHibernateTemplate().save(company);
			tx.commit();
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public void saveOrUpdate(Company company) {
		try {
			Transaction tx = getSession().beginTransaction();
			getHibernateTemplate().saveOrUpdate(company);
			tx.commit();
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public void lock(Company company) {
		try {
			Transaction tx = getSession().beginTransaction();
			getHibernateTemplate().lock(company, LockMode.NONE);
			tx.commit();
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public void delete(Company company) {
		try {
			Transaction tx = getSession().beginTransaction();
			getHibernateTemplate().delete(company);
			tx.commit();
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public Company merge(Company company) {
		try {
			return (Company) getHibernateTemplate().merge(company);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public Company findById(java.lang.Long id) {
		try {
			return (Company) getHibernateTemplate().get(Company.class, id);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public List findByExample(Company company) {
		try {
			return getHibernateTemplate().findByExample("Company", company);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public List getAll() {
		try {
			return getHibernateTemplate().loadAll(Company.class);
		} catch (RuntimeException re) {
			throw re;
		}
	}
}
